<template>
	<view class="">
		<view class="Ultramans">
			<u-tabs :list="list1" :scrollable=false @click="click"
				style="background-color: #fff;margin: 10px;border-radius: 10px;"> </u-tabs>
			<view class="" v-if="num == 0">
				<view class="Ultraman" v-for="(v,i) in ordeList">
					<view class="Ultraman_a"
						:style="{ backgroundColor: v.status == 1 ? '#fdb6ab' : v.status == 2 ? 'red' : '#72e4b0' }">
						{{v.status == 1?'待上门' :v.status == 2?'待支付':'已完成'}}
					</view>
					<view class="font_an">
						<view class="font_size">
							{{ v.categoryName}}
						</view>
						<view class="font_anfei" v-if="v.type == 1">
							平台服务费{{v.rate}}
						</view>
						<view class="font_anfei" v-else>
							平台服务费{{v.serviceFee}}
						</view>
					</view>
					<view class="font_anaio">
						联系电话：{{v.phone}}
					</view>
					<view class="font_anaio">
						上门地址：{{v.provinceName+v.cityName+v.regionName+v.address}}
					</view>
					<view class="font_anaios"> </view>
					<view class="font_antin">
						<view class="font_antin_se">
							上门时间：{{v.visitTime}}
						</view>
						<view class="" style="display: flex;" v-if="v.status == 1">
							<view class="font_antin_buttons" @click="quxiao(v.id)">
								取消
							</view>
							<view class="font_antin_button" @click="font_antin_button(v.id)">
								已到达
							</view>
						</view>
						<view class="" style="display: flex;" v-if="v.status == 2">
							<view class="font_antin_buttons" @click="quxiao(v.id)">
								取消
							</view>
							<view class="font_antin_button" @click="font_antin_buttons(v.id)">
								去支付
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="num == 1">
				<view class="Ultraman" v-for="(v,i) in ordeLista">
					<view class="Ultraman_a" :style="{ backgroundColor:favoriteGradient }">
						{{favoritext}}
					</view>
					<view class="font_an">
						<view class="font_size">
							{{ v.categoryName}}
						</view>
						<view class="font_anfei" v-if="v.type == 1">
							平台服务费{{v.rate}}
						</view>
						<view class="font_anfei" v-else>
							平台服务费{{v.serviceFee}}
						</view>
					</view>
					<view class="font_anaio">
						联系电话：{{v.phone}}
					</view>
					<view class="font_anaio">
						上门地址：{{v.provinceName+v.cityName+v.regionName+v.address}}
					</view>
					<view class="font_anaios"> </view>
					<view class="font_antin">
						<view class="font_antin_se">
							上门时间：{{v.visitTime}}
						</view>
						<view class="font_antin_buttons" @click="quxiao(v.id)">
							取消
						</view>
						<view class="font_antin_button" @click="font_antin_button">
							已到达
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="num === 2">
				<view class="Ultraman" v-for="(v,i) in ordeListb">
					<view class="Ultraman_a" :style="{ backgroundColor:favoriteGradient }">
						{{favoritext}}
					</view>
					<view class="font_an">
						<view class="font_size">
							{{ v.categoryName}}
						</view>
						<view class="font_anfei" v-if="v.type == 1">
							平台服务费{{v.rate}}
						</view>
						<view class="font_anfei" v-else>
							平台服务费{{v.serviceFee}}
						</view>
					</view>
					<view class="font_anaio">
						联系电话：{{v.phone}}
					</view>
					<view class="font_anaio">
						上门地址：{{v.provinceName+v.cityName+v.regionName+v.address}}
					</view>
					<view class="font_anaios"> </view>
					<view class="font_antin">
						<view class="font_antin_se">
							上门时间：{{v.visitTime}}
						</view>
						<view class="font_antin_buttons" @click="quxiao(v.id)">
							取消
						</view>
						<view class="font_antin_button" @click="font_antin_buttons">
							去支付
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="num == 3">
				<view class="Ultraman" v-for="(v,i) in ordeListc">
					<view class="Ultraman_a" :style="{ backgroundColor:favoriteGradient }">
						{{favoritext}}
					</view>
					<view class="font_an">
						<view class="font_size">
							{{ v.categoryName}}
						</view>
						<view class="font_anfei" v-if="v.type == 1">
							平台服务费{{v.rate}}
						</view>
						<view class="font_anfei" v-else>
							平台服务费{{v.serviceFee}}
						</view>
					</view>
					<view class="font_anaio">
						联系电话：{{v.phone}}
					</view>
					<view class="font_anaio">
						上门地址：{{v.provinceName+v.cityName+v.regionName+v.address}}
					</view>
					<view class="font_anaios"> </view>
					<view class="font_antin">
						<view class="font_antin_se">
							上门时间：{{v.visitTime}}
						</view>
					</view>
				</view>
			</view>


		</view>
		<bottom-tab url='/pages/index/Recallslip'></bottom-tab>

	</view>

</template>
<script>
	export default {
		data() {
			return {
				list1: [{
					name: '全部',
					id: 0,
				}, {
					name: '待上门',
					id: 1,
				}, {
					name: '待支付',
					id: 2,
				}, {
					name: '已完成',
					id: 3,
				}],
				num: 0,
				ordeList: [],
				ordeLista:[],
				ordeListb:[],
				ordeListc:[]
			}
		},
		onLoad() {
			this.oloda()
		},
		methods: {
			oloda() {
				this.$ajax('get', 'recovery/appointment_order/list', {
					pageSize: 10,
					pageNum: 1
				}).then((res) => {
					this.ordeList = res.rows
					console.log(this.ordeList);
				})
			},
			quxiao(e) {
				this.$ajax('get', 'recovery/appointment_order/cancel/' + e).then((res) => {
					if (res.code == 200) {
						this.oloda()
					} else {
						this.$api.msg(res.msg)
					}
				})
			},
			click(item) {
				console.log(item);
				if (item.id == 0) {
					this.$ajax('get', 'recovery/appointment_order/list', {
						pageSize: 10,
						pageNum: 1
					}).then((res) => {
						this.ordeList = res.rows
					})
				} else if(item.id == 1){
					this.$ajax('get', 'recovery/appointment_order/list', {
						pageSize: 10,
						pageNum: 1,
						status: 1
					}).then((res) => {
						this.ordeLista = res.rows
					})
				}else if(item.id == 2){
					this.$ajax('get', 'recovery/appointment_order/list', {
						pageSize: 10,
						pageNum: 1,
						status: 2
					}).then((res) => {
						this.ordeListb = res.rows
					})
				}else if(item.id == 3){
					this.$ajax('get', 'recovery/appointment_order/list', {
						pageSize: 10,
						pageNum: 1,
						status: 3
					}).then((res) => {
						this.ordeListc = res.rows
					})
				} 
				this.num = item.index
			},
			font_antin_button(e) {
				this.$ajax('get', 'recovery/appointment_order/toPay/' + e).then((res) => {
					if (res.code == 200) {
						uni.navigateTo({
							url: '../index/Payments?id=' + e
						})
					} else {
						this.$api.msg(res.msg)
					}
				})
			},
			font_antin_buttons(e) {
				this.$ajax('get', 'recovery/appointment_order/toPay/' + e).then((res) => {
					if (res.code == 200) {
						uni.navigateTo({
							url: '../index/Payments?id=' + e
						})
					} else {
						this.$api.msg(res.msg)
					}
				})
			}
		},
		computed: {
			favoriteGradient() {
				console.log(this.num);
				switch (this.num) {
					case 2:
						return `red`;
					case 3:
						return `#72e4b0`;
					case 1:
					default:
						return `#fdb6ab`
				}
			},
			favoritext() {
				switch (this.num) {
					case 2:
						return '待支付';
					case 3:
						return '已完成';
					case 1:
					default:
						return '待上门'
				}
			}
		},
	}
</script>

<style>
	page {
		background-color: #f6f6f6;
	}

	.font_antin {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 5px;
	}

	.font_antin_se {
		color: #a1a4a3;
		font-size: 15px;

	}

	.font_antin_button {
		margin-left: 5px;
		width: 70px;
		text-align: center;
		line-height: 30px;
		height: 30px;
		border-radius: 25px;
		font-weight: 500;
		color: #fff;
		background-image: linear-gradient(to right, #26a5fa, #268afe);
	}

	.font_antin_buttons {
		width: 70px;
		text-align: center;
		line-height: 30px;
		height: 30px;
		border-radius: 25px;
		font-weight: 500;
		color: #fff;
		background-color: #a3aeb3;
	}

	.Ultraman {
		position: relative;
		width: 90%;
		margin: 10px auto;
		background-color: #fff;
		border-radius: 10px;
		padding: 10px;
	}

	.Ultraman_a {
		position: absolute;
		right: 0;
		top: 0;
		border-radius: 0 10px 0 10px;
		width: 70px;
		text-align: center;
		line-height: 40px;
		font-size: 16px;
		color: #fff;
		height: 40px;

	}

	/* 	.color_a {
		background-color: #fdb6ab;
	}

	.color_b {
		background-color: #d1d0d0;
	}

	.color_c {
		background-image: linear-gradient(to right, #a1f5cf, #72e4b0);
	} */

	.font_anaios {
		background-color: #dfdfdf;
		height: 1px;
		width: 100%;
	}

	.font_anaio {
		margin: 10px 0;
		font-weight: 500;
		font-size: 18px;
	}

	.font_an {
		display: flex;
		align-items: center;

	}

	.font_anfei {
		background-color: #fef0e0;
		color: #fc9823;
		padding: 2px 10px;
		font-size: 14px;
		margin-left: 10px;
	}

	.font_size {
		font-weight: 600;
		font-size: 20px;
	}
</style>